package cn.iocoder.yudao.module.crossborder.risk.api;

import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.crossborder.risk.api.dto.ComplianceCheckDTO;
import cn.iocoder.yudao.module.crossborder.risk.api.dto.FraudDetectionDTO;
import cn.iocoder.yudao.module.crossborder.risk.api.dto.RiskAssessmentDTO;
import cn.iocoder.yudao.module.crossborder.risk.api.dto.RiskAssessmentReqDTO;
import cn.iocoder.yudao.module.crossborder.risk.service.RiskService;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.validation.annotation.Validated;

import javax.annotation.Resource;

import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;

/**
 * 风险管理 API 接口实现类
 *
 * @author LHL
 */
@RestController // 提供 RESTful API 接口，给 Feign 调用
@Validated
public class RiskApiImpl implements RiskApi {

    @Resource
    private RiskService riskService;

    @Override
    public CommonResult<RiskAssessmentDTO> assessRisk(RiskAssessmentReqDTO assessmentReq) {
        RiskAssessmentDTO result = riskService.assessRisk(assessmentReq);
        return success(result);
    }

    @Override
    public CommonResult<RiskAssessmentDTO> getRiskAssessment(Long id) {
        RiskAssessmentDTO assessment = riskService.getRiskAssessment(id);
        return success(assessment);
    }

    @Override
    public CommonResult<FraudDetectionDTO> detectFraud(Long userId, Long orderId) {
        FraudDetectionDTO result = riskService.detectFraud(userId, orderId);
        return success(result);
    }

    @Override
    public CommonResult<ComplianceCheckDTO> checkCompliance(String businessType, Long businessId) {
        ComplianceCheckDTO result = riskService.checkCompliance(businessType, businessId);
        return success(result);
    }

    @Override
    public CommonResult<Boolean> addBlacklist(String type, String value, String reason) {
        Boolean result = riskService.addBlacklist(type, value, reason);
        return success(result);
    }

    @Override
    public CommonResult<Boolean> removeBlacklist(String type, String value) {
        Boolean result = riskService.removeBlacklist(type, value);
        return success(result);
    }

    @Override
    public CommonResult<Boolean> checkBlacklist(String type, String value) {
        Boolean result = riskService.checkBlacklist(type, value);
        return success(result);
    }

}
